Re: [SQL] datediff function

Поиск
Список
Период
Сортировка
От Herouth Maoz
Тема Re: [SQL] datediff function
Дата
Msg-id l03130300b3def2007db9@[147.233.159.109]
обсуждение исходный текст
Ответ на Re: [SQL] datediff function  ("tjk@tksoft.com" <tjk@tksoft.com>)
Список pgsql-sql
At 02:26 +0300 on 17/08/1999, tjk@tksoft.com wrote:


>
> I think what you are looking for is age()
> E.g.
>
> "update schedule set purged = 0 where age('now',dayin) > timespan('30
>days'::reltime)"
>
> Presuming a table such as this:
>
> create table schedule (purged int, dayin datetime);
>
> This replaces "day" and "timein" with "dayin."

Basically correct, but if there is an index on dayin, it won't be used. The
best query to do would be

WHERE dayin > 'now'::datetime - '30 days'::timespan;

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




В списке pgsql-sql по дате отправления:

Предыдущее
От: Zsolt Varga
Дата:
Сообщение: Random function ?
Следующее
От: Herouth Maoz
Дата:
Сообщение: Re: [SQL] Stepping through a table.